/**********************************************************
 * Copyright © 2008，北京福富软件技术股份有限公司
 * All Rights Reserved.
 *
 * 文件名称： Attachment.java
 * 摘    要：
 *
 * 初始版本：1.0.0
 * 原 作 者：RUN
 * 完成日期：2009-9-4
 *
 * 当前版本：$LastChangedRevision$
 * 作    者：$LastChangedBy$
 * 完成日期：$LastChnagedDate$
 ************************************************************/
package aip.core.model.attachment;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;

import org.springframework.util.StringUtils;

/**
 * 附件
 * <p>
 * 负责人/principal: Daniel<br/>
 * 修改记录/revision:<br/>
 * 日期:<br/>
 * 修改人:<br/>
 * 修改说明:
 * @author RUN
 * @version $Id: codetemplates.xml 2007 2009-05-08 08:36:14Z shiw $
 */
@Entity
@Table(name = "COMM_ATTACHMENT")
public class Attachment implements Serializable
{
    private static final long serialVersionUID = -1743164274348419918L;
    public static final String TYPE_COMMON = "COMMON";
    public static final String TYPE_PHOTO = "PHOTO";

    /** ID */
    private int id;
    /** 附件类型：标准附件、照片附件、链接附件 */
    protected String type;
    /** 文件名（无后缀） */
    private String name;
    /** 后缀 */
    private String extension;
    /** 上传时间 */
    private Date create;
    /** 创建人 */
    private String creator;
    /** 实体ID */
    private int entityRefId;
    /** 文件内容，byte[](小文件)或InputStream(大文件) */
    private Object content;
    /** 链接附件的地址 */
    private String link;
    /** 存入的数据表 */
    private String tableName;

    /**
     * @return the id
     */
    @Id
    @Column(name = "ID_")
    public int getId()
    {
        return id;
    }

    /**
     * @param id
     *        the id to set
     */
    public void setId(int id)
    {
        this.id = id;
    }

    @Column(name = "NAME_")
    public String getName()
    {
        return name;
    }

    public void setName(String name)
    {
        this.name = name;
    }

    @Column(name = "EXTENSION_")
    public String getExtension()
    {
        return extension;
    }

    public void setExtension(String extension)
    {
        this.extension = extension;
    }

    @Column(name = "CREATE_")
    public Date getCreate()
    {
        return create;
    }

    public void setCreate(Date create)
    {
        this.create = create;
    }

    @Column(name = "CREATOR_")
    public String getCreator()
    {
        return creator;
    }

    public void setCreator(String creator)
    {
        this.creator = creator;
    }

    @Column(name = "ENTITY_REF_")
    public int getEntityRefId()
    {
        return entityRefId;
    }

    public void setEntityRefId(int entityRefId)
    {
        this.entityRefId = entityRefId;
    }

    @Column(name = "CONTENT_")
    public Object getContent()
    {
        return content;
    }

    public void setContent(Object content)
    {
        this.content = content;
    }

    @Column(name = "TYPE_")
    public String getType()
    {
        if (StringUtils.hasText(type))
        {
            return type;
        }
        else
        {
            return TYPE_COMMON;
        }
    }

    public void setType(String type)
    {
        this.type = type;
    }

    public String getTableName()
    {
        return tableName;
    }

    public void setTableName(String tableName)
    {
        this.tableName = tableName;
    }

    /**
     * @return the link
     */
    @Column(name = "LINK_")
    public String getLink()
    {
        return link;
    }

    /**
     * @param link
     *        the link to set
     */
    public void setLink(String link)
    {
        this.link = link;
    }

}
